export function formatRiskArgumentValue(value: any): string {
  if (value === null || value === undefined) return "";
  if (typeof value === "boolean") return value ? "true" : "false";
  if (typeof value === "object") {
    try {
      return JSON.stringify(value);
    } catch {
      return String(value);
    }
  }
  return String(value);
}

export function toRiskArgumentLines(
  args: Record<string, any> | undefined | null
): string[] {
  const entries = Object.entries(args || {});
  if (!entries.length) return [];
  return entries.map(
    ([key, value]) => `${key}: ${formatRiskArgumentValue(value)}`
  );
}

export function formatRiskArguments(
  args: Record<string, any> | undefined | null
): string {
  const lines = toRiskArgumentLines(args);
  return lines.length ? lines.join("\n") : "—";
}
